package de.dhbw.karlsruhe.picsim.gui;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import javax.swing.table.AbstractTableModel;

/**
 * Created by IntelliJ IDEA.
 * User: goesen
 * Date: Apr 13, 2010
 * Time: 11:45:11 PM
 */
final class ProgramMemoryTable extends AbstractTableModel {
    private static final Log log = LogFactory.getLog(ProgramMemoryTable.class);

    private final CommandRegister commandRegister;

    ProgramMemoryTable(final CommandRegister commandRegister) {
        this.commandRegister = commandRegister;
    }

    @Override
    public int getRowCount() {
        //TODO
        return 200;
    }


    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public boolean isCellEditable(int rowIndex, int columnIndex) {
        return columnIndex == 0;
    }

    @Override
    public void setValueAt(final Object aValue, int rowIndex, int columnIndex) {
        fireTableCellUpdated(rowIndex, columnIndex);
    }

    @Override
    public Object getValueAt(final int rowIndex, final int columnIndex) {
        return commandRegister.getCommandAt(rowIndex);
    }

    @Override
    public String getColumnName(final int column) {
        switch (column) {
            case 0:
                return "Break";
            case 1:
                return "Zeile";
            case 2:
                return "Opcode";
            case 3:
                return "Comment";
            default:
                log.error("Illegal column " + column);
                return super.getColumnName(column);
        }

    }
}
